package cn.study.cas;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Author     ：跟大佳一起学架构
 * @Description：演示基本类型的原子操作类
 */
public class UseAtomicInteger {
    static AtomicInteger ai = new AtomicInteger(10);

    public static void main(String[] args) {
        ai.getAndIncrement();
        ai.incrementAndGet();
        // 更新失败
        ai.compareAndSet(10,20);
        System.out.println(ai.get());
        ai.compareAndSet(12,20);
        System.out.println(ai.get());
        System.out.println(ai.addAndGet(30));
    }
}
